//
//  SCFillinLogisticsController.m
//  shangcheng
//
//  Created by 张艳江 on 2019/6/11.
//  Copyright © 2019 张艳江. All rights reserved.
//

#import "SCFillinLogisticsController.h"
#import "SCChooseWuliuController.h"

@interface SCFillinLogisticsController ()

@property (weak, nonatomic) IBOutlet UITextField *logisticsNumTF;
@property (weak, nonatomic) IBOutlet UILabel     *logisticsNameLab;

@end

@implementation SCFillinLogisticsController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.title = @"填写物流单号";
}
- (IBAction)clickChooseWuliuBtn:(UIButton *)sender {
    
    [self.view endEditing:YES];
    
    SCChooseWuliuController *vc = [[SCChooseWuliuController alloc]init];
    WeakSelf;
    vc.chooseWuliuName = ^(NSString * _Nonnull name) {
        weakSelf.logisticsNameLab.text = name;
    };
    [self.navigationController pushViewController:vc animated:YES];
}
- (IBAction)clickSubmitBtn:(UIButton *)sender {
    
    if (self.logisticsNumTF.text.length == 0) {
        [SVProgressHUD showImage:nil status:@"请填写正确的物流单号!"];
        return;
    }
    if (self.logisticsNameLab.text.length == 0) {
        [SVProgressHUD showImage:nil status:@"请选择您寄送的物流"];
        return;
    }
    NSDictionary *dict = @{@"type":self.type,
                           @"token":Token,
                           @"jd_express":self.logisticsNameLab.text,
                           @"jd_expNum":self.logisticsNumTF.text,
                           @"id":self.i_d};
    NSString *url = [MyTool splicingWithUrl:@"admin.php?g=System&c=GiftAppOrder&a=Service_expNum"];
    [SVProgressHUD showWithStatus:@"提交中..."];
    [[NetworkRequestTool sharedNetworkTool] POST:url parameters:dict finished:^(id result, NSString *error) {
        [SVProgressHUD showSuccessWithStatus:@"提交成功"];
        [self.navigationController popToViewController:[self.navigationController.viewControllers objectAtIndex:1] animated:YES];
    }];
}

@end
